import 'package:flutter/material.dart';

class DetailPage extends StatelessWidget {
  const DetailPage({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('DetailPage'),
        ),
        body: Center(
          child: Column(
            children: [
              const Text('DetailPage'),
              ElevatedButton(
                onPressed: () {
                  // 返回上一页
                  Navigator.pop(context);
                },
                child: const Text('返回'),
              ),
              ElevatedButton(
                onPressed: () {
                  // 点击弹窗(可以理解为：在路由中添加一个弹窗页面)
                  showDialog(
                    context: context,
                    builder: (context) {
                      return AlertDialog(
                        title: const Text('弹窗标题'),
                        content: const Text('弹窗内容'),
                        actions: [
                          TextButton(
                            onPressed: () {
                              // 点击确定按钮，关闭弹窗，从路由中移除
                              Navigator.pop(context);
                            },
                            child: const Text('确定'),
                          ),
                        ],
                      );
                    },
                  );
                },
                child: const Text('点击弹窗'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
